﻿namespace Example.Cryptography
{
    using System;
    using System.Text;

    public sealed class RijndaelPlaintext
    {
        private byte[] _plaintext;

        public RijndaelPlaintext(string plaintext)
            : this(Encoding.UTF8.GetBytes(plaintext))
        {
        }

        public RijndaelPlaintext(byte[] plaintext)
        {
            Plaintext = plaintext;
        }

        private byte[] Plaintext
        {
            get
            {
                return _plaintext;
            }

            set
            {
                if (null == value)
                {
                    throw new ArgumentNullException("value");
                }

                _plaintext = value;
            }
        }

        public byte[] ToBytes()
        {
            return Plaintext;
        }

        public override string ToString()
        {
            return Encoding.UTF8.GetString(Plaintext);
        }
    }
}